<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
    <script src="js/jquery-2.1.1.min.js"></script>
    <script src="js/loading.js"></script>
    <script src="js/jquery.cookie.js"></script>
    <script src="js/commonTool.js"></script>
     <script>
    $(function(){
      $("#header").load("header.html");
      var tarId=$.cookie('targetId');
      //var canManage=$.cookie('canManageTarget');
      var canManage="1";    
        
      var targetStat=Tool.tarStatus;
      var isNumber=Tool.isIntNumber;
      var addToken=Tool.addTokenToParams;
      var jdata={'targetId':tarId};
      showLoading();
      $.ajax({
    		  type: 'POST',
    		  url: doTargetGet,
    		  contentType:"application/json;charset=UTF-8",
    		  data:JSON.stringify(addToken(jdata)),
    		  xhrFields: {
    		  withCredentials: true
    		           },
    		  crossDomain: true,
    		  success: function(result){
                  hideLoading();
                  var data=result.data;
                  console.log(data);
                  var targetStatus=data.targetStatus;
                  $("#tar_title").text(data.targetTitle);
                  $("#tar_zn").text(data.userZn);
                  $("#tar_cost").text(data.targetCost);
                  $("#tar_user").text(data.userName);
                  $("#tar_time").text(data.beginDate+"-"+data.endDate);
                  $("#tar_stat").text(targetStat(targetStatus));
                  $("#tar_star").text(data.star);
                  $("#tar_cont").text(data.targetContent);
                  $("#tar_qt").text(data.otherExp);
                  if(canManage=="0"){
                      $("#sendfield").remove();
                  }else{
                      var sendBtn=$("#sendfield");
                      if(targetStatus=="0"){
                          sendBtn.children("button#pass").text("审批通过");
                          sendBtn.children("button#cancel").text("退回");
                      }else if(targetStatus=="2"){
                          sendBtn.children("button#pass").text("星级评定");
                          sendBtn.children("button#cancel").remove();
                      }else{
                          $("#sendfield").remove();
                      }
                  }
                 
    		  },error : function(xhr, errorType, error) {
                    hideLoading();
    				alert(errorType + ', ' + error);   
              }});
        
        
      $("#sendfield").find("button").click(function(){
         var btntxt=$(this).text();
          var jdata={'targetId':tarId};
         if(btntxt=="审批通过"){
             jdata['allowTarget']="1";
         }else if(btntxt=="退回"){
             jdata['allowTarget']="0";
         }else{
             console.log("111");
             star=prompt("请输入星级(数字)");
             if(!isNumber(star)){
                 alert("请输入数字");
                 return;
             }
             jdata['starNum']=star;
         }
         showLoading();
         $.ajax({
    		  type: 'POST',
    		  url: doTask_submit,
    		  contentType:"application/json;charset=UTF-8",
    		  data:JSON.stringify(addToken(jdata)),
    		  xhrFields: {
    		  withCredentials: true
    		           },
    		  crossDomain: true,
    		  success: function(result){
                  hideLoading();
                  var msg=result.result_msg;
                  if(msg=='success')
                    alert("提交成功!");
                  else
                      alert(msg);
                  location.reload();
    		  },error : function(xhr, errorType, error) {
                    hideLoading();
    				alert(errorType + ', ' + error);   
              }});
      
      
        });
      });
    </script>
    <link rel="stylesheet" href="css/style.css">
    <link rel="stylesheet" href="css/mainstyle.css">
    <style>
        .con_title{
            width: 100%;
            height: 5%;
            min-height: 25px;
            background-color: dodgerblue;
            color: white;
            text-align: left;
            display: table;
        }
        .con_title span{
            padding-left: 10px;
            display: table-cell;
            vertical-align: middle;
        }
        .con_cont{
            position: relative;
            width: 100%;
            height: 100%;
            min-height:500px;
        }
        
        .inner_tit{
            position: relative;
            margin-top: 10px;
            width: 100%;
    
        }
        .inner_tit span{
            float: left;
            margin-left: 5px;
        }
        .inner_cont{
            position: relative;
            width: 100%;
            height: 120px;
            margin-top: 10px;
            
        }
        .inner_cont span,textarea{
            float: left;
            margin-left: 5px;
       }
        textarea{
            width: 80%;
            height: 50%;
            min-height:110px;
        }
       
        #sendfield{
            text-align: center;
        }
    </style>
    <title>任务详情</title>
</head>
<body>
    <div id="header"></div>
    <div id="content">
    
        <div class="con_title"><span>任务详情</span></div>
        <div  class="con_cont">
            <div class="inner_tit">
            <span>标题:</span>
            <span id="tar_title" class="titlecls"></span>
            </div>
            <br>
            <div class="inner_tit">
            <span>职能:</span>
            <span id="tar_zn" class="titlecls"></span>
            </div>
            <br>
            <div class="inner_tit">
            <span>费用:</span>
            <span id="tar_cost" class="titlecls"></span>
            </div>
            <br>
            <div class="inner_tit">
            <span>创建者:</span>
            <span id="tar_user" class="titlecls"></span>
            </div>
            <br>
            <div class="inner_tit">
            <span>任务时间:</span>
            <span id="tar_time" class="titlecls"></span>
            </div>
            <br>
            <div class="inner_tit">
            <span>任务状态:</span>
            <span id="tar_stat" class="titlecls"></span>
            </div>
            <br>
            <div class="inner_tit">
            <span>任务星级:</span>
            <span id="tar_star" class="titlecls"></span>
            </div>
            <br>
             <div class="inner_cont"> 
            <span>内容:</span>
            <textarea id="tar_cont" class="contentcls" readonly="readonly"></textarea>
            </div>
            <div class="inner_cont"> 
            <span>其他:</span>
            <textarea id="tar_qt" class="contentcls" readonly="readonly"></textarea>
            </div>
            <br>
            <br>
            <div id="sendfield">
            <button id="pass">提交1</button>
            <br>
            <br>
            <button id="cancel">提交2</button>
            </div>
             
        </div>

        
        <br>
    </div>
</body>
</html>